package com.itheima.controller;

import com.itheima.common.CommonResult;
import com.itheima.service.NoticeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author wangjiexin
 */
@RestController
@RequestMapping("user/notice")
public class NoticeController {
    @Autowired
    NoticeService noticeService;

    //这边做系统通知 默认状态不开启为0 开启为1
    //允许给我推送喜欢通知
    @PutMapping("/like")
    public CommonResult myLike(@RequestBody int status){
         boolean res = noticeService.updateLikeStatus(status);
         if (!res){
             return CommonResult.error("设置喜欢通知失败");
         }
        return CommonResult.success(res);
    }

    //允许给我推送评论通知
    @PutMapping("/discuss")
    public CommonResult discuss(@RequestBody int status){
        boolean res = noticeService.updateDiscussStatus(status);
        if (!res){
            return CommonResult.error("设置评论通知失败");
        }
        return CommonResult.success(res);
    }
    //允许给我推送公告通知
    @PutMapping("/notice")
    public CommonResult notice(@RequestBody int status){
        boolean res = noticeService.updateNoticeStatus(status);
        if (!res){
            return CommonResult.error("设置公告通知失败");
        }
        return CommonResult.success(res);
    }
}
